package com.gjm.tool.utils;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class AAA {
    public static void main(String[] args) throws Exception {
        List<List<Object>> lists = readExcel();
        List<String> requestList = new ArrayList<>();
        List<String> localRequestList = new ArrayList<>();
        for (List<Object> list : lists) {
            if (list.size() <= 7){
                continue;
            }
            requestList.add(String.valueOf(list.get(7)));
        }

        JSONObject object1 = JSON.parseObject(FileUtil.readInfoFromFileToStr(Paths.get("C:\\Users\\Administrator\\Desktop\\1.txt")));
        JSONArray jsonArray1 = object1.getJSONObject("data").getJSONArray("resultList");

        JSONObject object2 = JSON.parseObject(FileUtil.readInfoFromFileToStr(Paths.get("C:\\Users\\Administrator\\Desktop\\2.txt")));
        JSONArray jsonArray2 = object2.getJSONObject("data").getJSONArray("resultList");

        JSONObject object3 = JSON.parseObject(FileUtil.readInfoFromFileToStr(Paths.get("C:\\Users\\Administrator\\Desktop\\3.txt")));
        JSONArray jsonArray3 = object3.getJSONObject("data").getJSONArray("resultList");

        jsonArray1.addAll(jsonArray2);
        jsonArray1.addAll(jsonArray3);

        for (Object o : jsonArray3) {
            JSONObject jsonObject = JSON.parseObject(o.toString());
            localRequestList.add(String.valueOf(jsonObject.get("requestId")));
        }

        List<String> collect = localRequestList.stream().filter(i -> !requestList.contains(i)).collect(Collectors.toList());
        for (String s : collect) {
            System.out.println(s);
        }
    }


    public static List<List<Object>> readExcel() {
        String filePath = "C:\\Users\\Administrator\\Desktop\\北京市朝阳实时出账结果文件_20250222041051.xlsx";
        ExcelReader reader = ExcelUtil.getReader(filePath, 0);
        // 读取指定sheet页面，0表示第一个sheet
        List<List<Object>> sheetList = reader.read(0);
        // 关闭读取器，释放资源
        reader.close();
        return sheetList.subList(2, sheetList.size());
    }
}
